package twitter.RequestHandler;

import java.io.PrintWriter;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantReadWriteLock;

import org.apache.log4j.BasicConfigurator;
import org.apache.log4j.Logger;

import twitter.TwitterLibrary.Utility;

public class DeleteServerHandler extends HTTPRequestHandler {
	private static Logger logger=Logger.getLogger(DeleteServerHandler.class);
	private final  ReentrantReadWriteLock rwl;
	private final Lock r;
	private final Lock w;
	private Utility utility;
	public DeleteServerHandler(ReentrantReadWriteLock rwl,Utility utility) {
		super(rwl,utility);
		BasicConfigurator.configure();
		this.rwl=rwl;
		this.r=rwl.readLock();
		this.w=rwl.writeLock();
		this.utility=utility;
		// TODO Auto-generated constructor stub
	}
	@Override
	public void parseHttpRequest(String httpInput, PrintWriter httpOutput) {
		// TODO Auto-generated method stub
		String server=httpInput.substring(0, httpInput.indexOf("remove"));
		System.out.println("received one delete server information");
		logger.info("received one delete server information");
		//String result=parser.readQueries(query);
		
		//String servers=query.substring(query.indexOf(" "));
		//System.out.println("***********In notice response ********primary server receive one notice response message "+query);
		
		utility.deleteServer(server.trim());
		
		
		
		
		//*************************
	
		

	}

}
